<?php

/**
 * This is the model class for table "lap_ppat".
 *
 * The followings are the available columns in table 'lap_ppat':
 * @property integer $id_lap
 * @property string $no_op
 * @property string $kode_ppat
 * @property string $tgl_lap
 * @property double $denda
 * @property string $kode_user
 *
 * The followings are the available model relations:
 * @property ObjekPajak $noOp
 * @property Ppat $kodePpat
 * @property Users $kodeUser
 */
class LapPpat extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'lap_ppat';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('no_op, kode_ppat, tgl_lap, denda, kode_user', 'required'),
			array('denda', 'numerical'),
			array('no_op', 'length', 'max'=>18),
			array('kode_ppat', 'length', 'max'=>17),
			array('kode_user', 'length', 'max'=>8),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id_lap, no_op, kode_ppat, tgl_lap, denda, kode_user', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'noOp' => array(self::BELONGS_TO, 'ObjekPajak', 'no_op'),
			'kodePpat' => array(self::BELONGS_TO, 'Ppat', 'kode_ppat'),
			'kodeUser' => array(self::BELONGS_TO, 'Users', 'kode_user'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id_lap' => 'Id Lap',
			'no_op' => 'No Op',
			'kode_ppat' => 'Kode Ppat',
			'tgl_lap' => 'Tgl Lap',
			'denda' => 'Denda',
			'kode_user' => 'Kode User',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id_lap',$this->id_lap);
		$criteria->compare('no_op',$this->no_op,true);
		$criteria->compare('kode_ppat',$this->kode_ppat,true);
		$criteria->compare('tgl_lap',$this->tgl_lap,true);
		$criteria->compare('denda',$this->denda);
		$criteria->compare('kode_user',$this->kode_user,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return LapPpat the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
